<?php

namespace yunj\enum;

use yunj\Enum;

final class BuilderType extends Enum {

    const FORM = 'yunj_form';

    const TABLE = 'yunj_table';

    const IMPORT = 'yunj_import';

    public static function options(): array {
        $options = [
            self::FORM => [
                "title" => "表单",
                "class" => "\\yunj\\builder\\YunjForm"
            ],
            self::TABLE => [
                "title" => "表格",
                "class" => "\\yunj\\builder\\YunjTable"
            ],
            self::IMPORT => [
                "title" => "导入",
                "class" => "\\yunj\\builder\\YunjImport"
            ],
        ];
        return $options;
    }

    public static function getClass(string $type, bool $is_full = true): string {
        $options = static::attrOptions("class");
        if (!isset($options[$type])) return "";
        $class = $options[$type];
        return $is_full ? $class : (substr($options[$type], strrpos($options[$type], "\\") + 1));
    }

}